/*
Created by Vadim Shchemelinin aka badger 
2012 St.Petersburg

Random start positions.

Return selected pos object.

0 = [[[objects1],[...],[objN]],[start1,...,startM],radius] execVM "bgr_RandomStart.sqf";

0 = [[[car],units gr1,units gr2],[start,start_1,start_2],20] execVM "bgr_RandomStart.sqf";
*/

if (!isServer) exitWith {};
_objects = _this select 0;
_poses = _this select 1;
_rad = _this select 2;

_selectedPos = _poses select (floor(random(count _poses)));
_Pos = getPosATL _selectedPos;

_object = (_objects select 0) select 0;

_initPos = getPosATL _object;

{
	{
		_dposX = (_initPos select 0) - (getposATL _x select 0);
		_dposY = (_initPos select 1) - (getposATL _x select 1);
		_posZ = (getposATL _x select 2);
		_randX = _rad/2 - random(_rad);
		_randY = _rad/2 - random(_rad);
		_x setPosATL [(_Pos select 0) + _dposX + _randX, (_Pos select 1) + _dposY + _randY, _posZ];
	} foreach _x;
} foreach _objects;

_selectedPos